<template>
	<view>
		<cu-custom :isBack="true">
		</cu-custom>
		<view>
			<view class="flex bg-white justify-between" v-for="(item,index) in articleList" :key="index"
				@tap="gotoCompanyContent(item)">
				<view class="margin-left">
					<view class="text-sm margin-top">{{item.title}}</view>
					<view class="text-gray text-cut margin-top-xs text-df">
						{{item.summary}}
					</view>
					<view class="text-sm text-grey margin-top-xs">{{formatDateTime(item.updateDate)}}</view>
				</view>
				<view class="cu-avatar margin" style="height: 50px;width: 50px;"
					:style="{'background-image':`url(${item.iconUrl})`}"></view>
			</view>
		</view>
	</view>
</template>

<script>
	import {formatDateTime} from '@/util/formatTime.js'
	import * as commonCompanyArticleApi from '@/api/common/commonCompanyArticleApi.js'
	import * as storage from '@/util/storage.js'
	export default {
		data() {
			return {
				articleList: [],
				companyId: storage.getCompanyId(),
			}
		},
		computed: {
			themeConfig() {
				return this.$store.state.themeConfig
			}
		},
		created() {
			this.listCompanyArticle()
		},
		methods: {
			gotoCompanyContent(item) {
				uni.navigateTo({
					url: `/pages/articleContent/articleContent?articleId=${item.articleId}`
				})
			},
			formatDateTime(timestamp) {
				return formatDateTime(timestamp, this.$t('unKnow'))
			},
			listCompanyArticle() {
				commonCompanyArticleApi.listCompanyArticle({
					companyId: this.companyId
				}).then(res => {
					const {
						data
					} = res
					this.articleList = data
				})
			}
		}
	}
</script>

<style>

</style>
